 OSGExport 
===========

 This script allows you to model in blender and export your models for
use in realtime OSG applications.

 Description:
==============
 This script allows you to model in blender and export your models for
use in OSG applications.

Hierarchies:
 * This script tries it's best to recreate a OSG node graph that
   represents the Blender scene.  The clock.blend example has most
   objects parented by the clock's wooden frame.  The pendulum, however,
   is parented to an 'empty' which allows rotation in an unusual location
   ( I know I could have shifted the mesh to move it's origin elsewhere,
     but I wanted to demonstrate an 'Empty' object.)

Animations:
 * This script will update the blender scene, once for each defined frame
   during export.  These matrices can be controlled using keyframes,
   the Ipo Editor, and curve paths!
 * The mesh objects are written to a hidden collection node (osg::Switch)
   and then are referenced from each child of an osg::Sequence.

Mesh Animations:
 * By setting the "Mesh Mode" menu option to "Deforms", you can enable
   the saving of one mesh per frame, for meshes that are the child of an
   Armature.
   Warning! This can make VERY BIG output files.
   Warning! This is not fast!  A complex scene with big meshes will
            take time...
   Note: This causes all the frames of the animation to be redrawn one
         additional time.
 * Read http://download.blender.org/documentation/html/
   for a description on how to make an animation with mesh deformations.

Limitations:
 * It only exports meshes of lines, triangles and quads
   Other nodes are exported as 'Empty' in order to maintain the
   scene hierarchy, but will not be visible (ie., NURBS sphere etc...)

 * Color Materials:
   * I doubt the material/colour code is (even close to) perfect
   * Make sure the brown OB button is set to link the material 
     to an object... or you get nothing! (OB tooltip:"Link material to object")
   * Only the first material is used.

USAGE ####################################################################

1. Into blender menus

Put the .py file into $HOME/.blender/scripts/ directory
Restart blender and you will have a new exporter into the File menu.

2. Manually

 Start blender.  Load/Create your scene.
 In blender, open the Text Editor and load this script. Type ALT+P

In any of both cases:

 A GUI will appear.
   The start and end frame numbers will be displayed, to remind you
   about how many animation frames are defined.  The default is 250!
   (Use the Animation buttons to set the end frame.)
 FPS:
   You can now set the Frames Per Second.  This will calculate the Delay
   of each sequence item.  Default of 24 is a bit twitchy on my GeForce4...
   30 looks quite good.
 Repeat Mode:
   You can specify a repeat mode of LOOP or SWING.
 Mesh Mode:
   Specifying 'Static' for the mesh mode means the use of Armatures
   for mesh deformations is NOT used.
   Specifying 'Deform' means that one mesh per frame will be generated
   for meshes that are a child of an armature object.

 Once you are set, hit the "Export" button!
 Hit the "Done" button to return to the text editor.

 Load the exported file using 'osgviewer' and enjoy:
  > osgviewer output.osg
   
EXAMPLES ##################################################################
 These examples assume you know Blender reasonably well.
 - Clock
 The clock is an example of a hierarchical scene, with IPO animation.
    Load the clock.blend file into blender.
    Load and run the BlendOSG.py Python script.
    Select "Swing" mode. Set the FPS to 30 or 40
    Set the output file to clock.osg
    Hit the Export Button.

    run the scene!
      osgviewer clock.osg

 - Monkey
 The monkey is an example of a mesh deformation animation.
    Load the monkey.blend file into blender.
    Load and run the BlendOSG.py script
    Select the "Swing" mode.
    Set the output file to monkeyears.osg
    Set the Mesh Mode to "Deform"
    Hit the export button.

    run the scene!
      osgviewer monkeyears.osg
 Note: Some blender versions crash when exporting this model. There may be
     some bug in the blender python API.


 Finally, run them both to get a really wierd clock:
     osgviewer clock.osg monkeyears.osg
